<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let obj = {
            name:"老王哥",
            age:18,
            se:"男"
        }
        // 没有symbol-iterator方法
        // 自己写一个
        Object.prototype[Symbol.iterator] = function(){
            // 获取所有obj属性的值
            let vals = Object.values(this); //['老王哥', 18, '男']
            // console.log(vals);
            let index = 0;
            return {
              next:function(){
                return {
                   value:vals[index],
                   done:vals.length===index++,
                }
              }
            }
        }

        for(let item of obj){
            console.log(item);
        }

        // 迭代器对象 - next方法
        // let keys = Object.keys(obj);
        // console.log(keys);

        // let arr = [1,2,3,4]

        // let keys = arr.keys();
        // console.log(keys);
        // let res = keys.next();
        // console.log(res);


       
    </script>
</body>
</html>